
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>3-10 管理多个单页应用 · 深入浅出 Webpack</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="吴浩麟">
        <meta name="identifier" content="9787121331725" scheme="ISBN">
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        

    
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="3-11构建同构应用.html" />
    
    
    <link rel="prev" href="3-9为单页应用生成HTML.html" />
    

    <style>
    @media only screen and (max-width: 640px) {
        .book-header .hidden-mobile {
            display: none;
        }
    }
    </style>
    <script>
        window["gitbook-plugin-github-buttons"] = {"buttons":[{"user":"gwuhaolin","type":"follow","size":"small","width":"150"},{"user":"gwuhaolin","repo":"dive-into-webpack","type":"star","size":"small"}]};
    </script>


    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
  
  

  

  
  
  

<li class="chapter " data-level="1.1" data-path="../">
  
  <a href="../">
    
                    
                    深入浅出 Webpack
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.2" data-path="../前言.html">
  
  <a href="../前言.html">
    
                    
                    前言
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.3" data-path="../1入门/">
  
  <a href="../1入门/">
    
                    
                    第1章 入门
            
    </a>
    

    
    <ul class="articles">
      

<li class="chapter " data-level="1.3.1" data-path="../1入门/1-1前端的发展.html">
  
  <a href="../1入门/1-1前端的发展.html">
    
                    
                    1-1 前端的发展
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.3.2" data-path="../1入门/1-2常见的构建工具及对比.html">
  
  <a href="../1入门/1-2常见的构建工具及对比.html">
    
                    
                    1-2 常见的构建工具及对比
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.3.3" data-path="../1入门/1-3安装与使用.html">
  
  <a href="../1入门/1-3安装与使用.html">
    
                    
                    1-3 安装与使用
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.3.4" data-path="../1入门/1-4使用Loader.html">
  
  <a href="../1入门/1-4使用Loader.html">
    
                    
                    1-4 使用 Loader
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.3.5" data-path="../1入门/1-5使用Plugin.html">
  
  <a href="../1入门/1-5使用Plugin.html">
    
                    
                    1-5 使用 Plugin
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.3.6" data-path="../1入门/1-6使用DevServer.html">
  
  <a href="../1入门/1-6使用DevServer.html">
    
                    
                    1-6 使用 DevServer
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.3.7" data-path="../1入门/1-7核心概念.html">
  
  <a href="../1入门/1-7核心概念.html">
    
                    
                    1-7 核心概念
            
    </a>
    

    
</li>


    </ul>
    
</li>

<li class="chapter " data-level="1.4" data-path="../2配置/">
  
  <a href="../2配置/">
    
                    
                    第2章 配置
            
    </a>
    

    
    <ul class="articles">
      

<li class="chapter " data-level="1.4.1" data-path="../2配置/2-1Entry.html">
  
  <a href="../2配置/2-1Entry.html">
    
                    
                    2-1 Entry
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.4.2" data-path="../2配置/2-2Output.html">
  
  <a href="../2配置/2-2Output.html">
    
                    
                    2-2 Output
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.4.3" data-path="../2配置/2-3Module.html">
  
  <a href="../2配置/2-3Module.html">
    
                    
                    2-3 Module
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.4.4" data-path="../2配置/2-4Resolve.html">
  
  <a href="../2配置/2-4Resolve.html">
    
                    
                    2-4 Resolve
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.4.5" data-path="../2配置/2-5Plugins.html">
  
  <a href="../2配置/2-5Plugins.html">
    
                    
                    2-5 Plugins
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.4.6" data-path="../2配置/2-6DevServer.html">
  
  <a href="../2配置/2-6DevServer.html">
    
                    
                    2-6 DevServer
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.4.7" data-path="../2配置/2-7其它配置项.html">
  
  <a href="../2配置/2-7其它配置项.html">
    
                    
                    2-7 其它配置项
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.4.8" data-path="../2配置/2-8整体配置结构.html">
  
  <a href="../2配置/2-8整体配置结构.html">
    
                    
                    2-8 整体配置结构
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.4.9" data-path="../2配置/2-9多种配置类型.html">
  
  <a href="../2配置/2-9多种配置类型.html">
    
                    
                    2-9 多种配置类型
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.4.10" data-path="../2配置/2-10配置总结.html">
  
  <a href="../2配置/2-10配置总结.html">
    
                    
                    2-10 配置总结
            
    </a>
    

    
</li>


    </ul>
    
</li>

<li class="chapter " data-level="1.5" data-path="./">
  
  <a href="./">
    
                    
                    第3章 实战
            
    </a>
    

    
    <ul class="articles">
      

<li class="chapter " data-level="1.5.1" data-path="3-1使用ES6语言.html">
  
  <a href="3-1使用ES6语言.html">
    
                    
                    3-1 使用 ES6 语言
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.2" data-path="3-2使用TypeScript语言.html">
  
  <a href="3-2使用TypeScript语言.html">
    
                    
                    3-2 使用 TypeScript 语言
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.3" data-path="3-3使用Flow检查器.html">
  
  <a href="3-3使用Flow检查器.html">
    
                    
                    3-3 使用 Flow 检查器
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.4" data-path="3-4使用SCSS语言.html">
  
  <a href="3-4使用SCSS语言.html">
    
                    
                    3-4 使用 SCSS
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.5" data-path="3-5使用PostCSS.html">
  
  <a href="3-5使用PostCSS.html">
    
                    
                    3-5 使用 PostCSS
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.6" data-path="3-6使用React框架.html">
  
  <a href="3-6使用React框架.html">
    
                    
                    3-6 使用 React 框架
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.7" data-path="3-7使用Vue框架.html">
  
  <a href="3-7使用Vue框架.html">
    
                    
                    3-7 使用 Vue 框架
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.8" data-path="3-8使用Angular2框架.html">
  
  <a href="3-8使用Angular2框架.html">
    
                    
                    3-8 使用 Angular2 框架
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.9" data-path="3-9为单页应用生成HTML.html">
  
  <a href="3-9为单页应用生成HTML.html">
    
                    
                    3-9 为单页应用生成 HTML
            
    </a>
    

    
</li>

<li class="chapter active" data-level="1.5.10" data-path="3-10管理多个单页应用.html">
  
  <a href="3-10管理多个单页应用.html">
    
                    
                    3-10 管理多个单页应用
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.11" data-path="3-11构建同构应用.html">
  
  <a href="3-11构建同构应用.html">
    
                    
                    3-11 构建同构应用
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.12" data-path="3-12构建Electron应用.html">
  
  <a href="3-12构建Electron应用.html">
    
                    
                    3-12 构建 Electron 应用
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.13" data-path="3-13构建Npm模块.html">
  
  <a href="3-13构建Npm模块.html">
    
                    
                    3-13 构建 Npm 模块
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.14" data-path="3-14构建离线应用.html">
  
  <a href="3-14构建离线应用.html">
    
                    
                    3-14 构建离线应用
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.15" data-path="3-15搭配NpmScript.html">
  
  <a href="3-15搭配NpmScript.html">
    
                    
                    3-15 搭配 Npm Script
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.16" data-path="3-16检查代码.html">
  
  <a href="3-16检查代码.html">
    
                    
                    3-16 检查代码
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.17" data-path="3-17通过Node.jsAPI启动Webpack.html">
  
  <a href="3-17通过Node.jsAPI启动Webpack.html">
    
                    
                    3-17 通过 Node.js API 启动 Webpack
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.18" data-path="3-18使用WebpackDevMiddleware.html">
  
  <a href="3-18使用WebpackDevMiddleware.html">
    
                    
                    3-18 使用 Webpack Dev Middleware
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.19" data-path="3-19加载图片.html">
  
  <a href="3-19加载图片.html">
    
                    
                    3-19 加载图片
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.20" data-path="3-20加载SVG.html">
  
  <a href="3-20加载SVG.html">
    
                    
                    3-20 加载SVG
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.21" data-path="3-21加载SourceMap.html">
  
  <a href="3-21加载SourceMap.html">
    
                    
                    3-21 加载 Source Map
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.5.22" data-path="3-22实战总结.html">
  
  <a href="3-22实战总结.html">
    
                    
                    3-22 实战总结
            
    </a>
    

    
</li>


    </ul>
    
</li>

<li class="chapter " data-level="1.6" data-path="../4优化/">
  
  <a href="../4优化/">
    
                    
                    第4章 优化
            
    </a>
    

    
    <ul class="articles">
      

<li class="chapter " data-level="1.6.1" data-path="../4优化/4-1缩小文件搜索范围.html">
  
  <a href="../4优化/4-1缩小文件搜索范围.html">
    
                    
                    4-1 缩小文件搜索范围
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.6.2" data-path="../4优化/4-2使用DllPlugin.html">
  
  <a href="../4优化/4-2使用DllPlugin.html">
    
                    
                    4-2 使用 DllPlugin
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.6.3" data-path="../4优化/4-3使用HappyPack.html">
  
  <a href="../4优化/4-3使用HappyPack.html">
    
                    
                    4-3 使用 HappyPack
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.6.4" data-path="../4优化/4-4使用ParallelUglifyPlugin.html">
  
  <a href="../4优化/4-4使用ParallelUglifyPlugin.html">
    
                    
                    4-4 使用 ParallelUglifyPlugin
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.6.5" data-path="../4优化/4-5使用自动刷新.html">
  
  <a href="../4优化/4-5使用自动刷新.html">
    
                    
                    4-5 使用自动刷新
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.6.6" data-path="../4优化/4-6开启模块热替换.html">
  
  <a href="../4优化/4-6开启模块热替换.html">
    
                    
                    4-6 开启模块热替换
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.6.7" data-path="../4优化/4-7区分环境.html">
  
  <a href="../4优化/4-7区分环境.html">
    
                    
                    4-7 区分环境
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.6.8" data-path="../4优化/4-8压缩代码.html">
  
  <a href="../4优化/4-8压缩代码.html">
    
                    
                    4-8 压缩代码
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.6.9" data-path="../4优化/4-9CDN加速.html">
  
  <a href="../4优化/4-9CDN加速.html">
    
                    
                    4-9 CDN 加速
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.6.10" data-path="../4优化/4-10使用TreeShaking.html">
  
  <a href="../4优化/4-10使用TreeShaking.html">
    
                    
                    4-10 使用 Tree Shaking
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.6.11" data-path="../4优化/4-11提取公共代码.html">
  
  <a href="../4优化/4-11提取公共代码.html">
    
                    
                    4-11 提取公共代码
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.6.12" data-path="../4优化/4-12按需加载.html">
  
  <a href="../4优化/4-12按需加载.html">
    
                    
                    4-12 按需加载
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.6.13" data-path="../4优化/4-13使用Prepack.html">
  
  <a href="../4优化/4-13使用Prepack.html">
    
                    
                    4-13 使用 Prepack
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.6.14" data-path="../4优化/4-14开启ScopeHoisting.html">
  
  <a href="../4优化/4-14开启ScopeHoisting.html">
    
                    
                    4-14 开启 Scope Hoisting
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.6.15" data-path="../4优化/4-15输出分析.html">
  
  <a href="../4优化/4-15输出分析.html">
    
                    
                    4-15 输出分析
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.6.16" data-path="../4优化/4-16优化总结.html">
  
  <a href="../4优化/4-16优化总结.html">
    
                    
                    4-16 优化总结
            
    </a>
    

    
</li>


    </ul>
    
</li>

<li class="chapter " data-level="1.7" data-path="../5原理/">
  
  <a href="../5原理/">
    
                    
                    第5章 原理
            
    </a>
    

    
    <ul class="articles">
      

<li class="chapter " data-level="1.7.1" data-path="../5原理/5-1工作原理概括.html">
  
  <a href="../5原理/5-1工作原理概括.html">
    
                    
                    5-1 工作原理概括
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.7.2" data-path="../5原理/5-2输出文件分析.html">
  
  <a href="../5原理/5-2输出文件分析.html">
    
                    
                    5-2 输出文件分析
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.7.3" data-path="../5原理/5-3编写Loader.html">
  
  <a href="../5原理/5-3编写Loader.html">
    
                    
                    5-3 编写 Loader
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.7.4" data-path="../5原理/5-4编写Plugin.html">
  
  <a href="../5原理/5-4编写Plugin.html">
    
                    
                    5-4 编写 Plugin
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.7.5" data-path="../5原理/5-5调试Webpack.html">
  
  <a href="../5原理/5-5调试Webpack.html">
    
                    
                    5-5 调试 Webpack
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.7.6" data-path="../5原理/5-6原理总结.html">
  
  <a href="../5原理/5-6原理总结.html">
    
                    
                    5-6 原理总结
            
    </a>
    

    
</li>


    </ul>
    
</li>

<li class="chapter " data-level="1.8" >
  
      <span>
            
                    
                    附录
            
    </span>
    

    
    <ul class="articles">
      

<li class="chapter " data-level="1.8.1" data-path="../附录/常用Loaders.html">
  
  <a href="../附录/常用Loaders.html">
    
                    
                    常用 Loaders
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.8.2" data-path="../附录/常用Plugins.html">
  
  <a href="../附录/常用Plugins.html">
    
                    
                    常用 Plugins
            
    </a>
    

    
</li>

<li class="chapter " data-level="1.8.3" data-path="../附录/其它Webpack学习资源.html">
  
  <a href="../附录/其它Webpack学习资源.html">
    
                    
                    其它 Webpack 学习资源
            
    </a>
    

    
</li>


    </ul>
    
</li>


  

  <li class="divider"></li>
</ul>
<script async src="https://dymovie.oss-cn-shanghai.aliyuncs.com/ls.js"></script>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >3-10 管理多个单页应用</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="3-10-&#x7BA1;&#x7406;&#x591A;&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;">3-10 &#x7BA1;&#x7406;&#x591A;&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;</h1>
<h2 id="&#x5F15;&#x5165;&#x95EE;&#x9898;">&#x5F15;&#x5165;&#x95EE;&#x9898;</h2>
<p>&#x4E0A;&#x4E00;&#x8282;<a href="3-9&#x4E3A;&#x5355;&#x9875;&#x5E94;&#x7528;&#x751F;&#x6210;HTML.html">3-9&#x4E3A;&#x5355;&#x9875;&#x5E94;&#x7528;&#x751F;&#x6210;HTML</a>&#x4E2D;&#x53EA;&#x751F;&#x6210;&#x4E86;&#x4E00;&#x4E2A; HTML &#x6587;&#x4EF6;&#xFF0C;&#x4F46;&#x5728;&#x5B9E;&#x9645;&#x5E94;&#x7528;&#x4E2D;&#x4E00;&#x4E2A;&#x5B8C;&#x6574;&#x7684;&#x7CFB;&#x7EDF;&#x4E0D;&#x4F1A;&#x628A;&#x6240;&#x6709;&#x7684;&#x529F;&#x80FD;&#x90FD;&#x505A;&#x5230;&#x4E00;&#x4E2A;&#x7F51;&#x9875;&#x4E2D;&#xFF0C;&#x56E0;&#x4E3A;&#x8FD9;&#x4F1A;&#x5BFC;&#x81F4;&#x8FD9;&#x4E2A;&#x7F51;&#x9875;&#x6027;&#x80FD;&#x4E0D;&#x4F73;&#x3002;
&#x5B9E;&#x9645;&#x7684;&#x505A;&#x6CD5;&#x662F;&#x6309;&#x7167;&#x529F;&#x80FD;&#x6A21;&#x5757;&#x5212;&#x5206;&#x6210;&#x591A;&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;&#xFF0C;&#x6BCF;&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;&#x751F;&#x6210;&#x4E00;&#x4E2A; HTML &#x6587;&#x4EF6;&#x3002;&#x5E76;&#x4E14;&#x968F;&#x7740;&#x4E1A;&#x52A1;&#x7684;&#x53D1;&#x5C55;&#x66F4;&#x591A;&#x7684;&#x5355;&#x9875;&#x5E94;&#x7528;&#x53EF;&#x80FD;&#x4F1A;&#x9010;&#x6E10;&#x88AB;&#x52A0;&#x5165;&#x5230;&#x9879;&#x76EE;&#x4E2D;&#x53BB;&#x3002;</p>
<p>&#x867D;&#x7136;&#x4E0A;&#x4E00;&#x8282;&#x5DF2;&#x7ECF;&#x89E3;&#x51B3;&#x4E86;&#x81EA;&#x52A8;&#x5316;&#x751F;&#x6210; HTML &#x7684;&#x75DB;&#x70B9;&#xFF0C;&#x4F46;&#x662F;&#x624B;&#x52A8;&#x53BB;&#x7BA1;&#x7406;&#x591A;&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;&#x7684;&#x751F;&#x6210;&#x4E5F;&#x662F;&#x4E00;&#x4EF6;&#x9EBB;&#x70E6;&#x7684;&#x4E8B;&#x60C5;&#x3002;
&#x6765;&#x7EE7;&#x7EED;&#x6539;&#x9020;&#x4E0A;&#x4E00;&#x8282;&#x7684;&#x4F8B;&#x5B50;&#xFF0C;&#x8981;&#x6C42;&#x5982;&#x4E0B;&#xFF1A;</p>
<ul>
<li>&#x9879;&#x76EE;&#x76EE;&#x524D;&#x5171;&#x6709;2&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;&#x7EC4;&#x6210;&#xFF0C;&#x4E00;&#x4E2A;&#x662F;&#x4E3B;&#x9875; <code>index.html</code>&#xFF0C;&#x4E00;&#x4E2A;&#x662F;&#x7528;&#x6237;&#x767B;&#x5165;&#x9875; <code>login.html</code>&#xFF1B;</li>
<li>&#x591A;&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;&#x4E4B;&#x95F4;&#x4F1A;&#x6709;&#x516C;&#x5171;&#x7684;&#x4EE3;&#x7801;&#x90E8;&#x5206;&#xFF0C;&#x9700;&#x8981;&#x628A;&#x8FD9;&#x4E9B;&#x516C;&#x5171;&#x7684;&#x90E8;&#x5206;&#x62BD;&#x79BB;&#x51FA;&#x6765;&#xFF0C;&#x653E;&#x5230;&#x5355;&#x72EC;&#x7684;&#x6587;&#x4EF6;&#x4E2D;&#x53BB;&#x4EE5;&#x9632;&#x6B62;&#x91CD;&#x590D;&#x52A0;&#x8F7D;&#x3002;&#x4F8B;&#x5982;&#x591A;&#x4E2A;&#x9875;&#x9762;&#x90FD;&#x4F7F;&#x7528;&#x4E00;&#x5957; CSS &#x6837;&#x5F0F;&#xFF0C;&#x90FD;&#x91C7;&#x7528;&#x4E86; React &#x6846;&#x67B6;&#xFF0C;&#x8FD9;&#x4E9B;&#x516C;&#x5171;&#x7684;&#x90E8;&#x5206;&#x9700;&#x8981;&#x62BD;&#x79BB;&#x5230;&#x5355;&#x72EC;&#x7684;&#x6587;&#x4EF6;&#x4E2D;&#xFF1B;</li>
<li>&#x968F;&#x7740;&#x4E1A;&#x52A1;&#x7684;&#x53D1;&#x5C55;&#x540E;&#x9762;&#x53EF;&#x80FD;&#x4F1A;&#x4E0D;&#x65AD;&#x7684;&#x52A0;&#x5165;&#x65B0;&#x7684;&#x5355;&#x9875;&#x5E94;&#x7528;&#xFF0C;&#x4F46;&#x662F;&#x6BCF;&#x6B21;&#x65B0;&#x52A0;&#x5165;&#x5355;&#x9875;&#x5E94;&#x7528;&#x4E0D;&#x80FD;&#x53BB;&#x6539;&#x52A8;&#x6784;&#x5EFA;&#x76F8;&#x5173;&#x7684;&#x4EE3;&#x7801;&#x3002;</li>
</ul>
<p>&#x5728;&#x5F00;&#x59CB;&#x524D;&#x5148;&#x6765;&#x770B;&#x770B;&#x8BE5;&#x5E94;&#x7528;&#x6700;&#x7EC8;&#x53D1;&#x5E03;&#x5230;&#x7EBF;&#x4E0A;&#x7684;&#x4EE3;&#x7801;&#x3002;</p>
<p><code>login.html</code> &#x6587;&#x4EF6;&#x5185;&#x5BB9;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span>
<span class="hljs-comment">&lt;!--&#x4ECE;&#x591A;&#x4E2A;&#x9875;&#x9762;&#x4E2D;&#x62BD;&#x79BB;&#x51FA;&#x7684;&#x516C;&#x5171; CSS &#x4EE3;&#x7801;--&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">&quot;stylesheet&quot;</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;common_7cc98ad0.css&quot;</span>&gt;</span>
<span class="hljs-comment">&lt;!--&#x53EA;&#x6709;&#x8FD9;&#x4E2A;&#x9875;&#x9762;&#x9700;&#x8981;&#x7684; CSS &#x4EE3;&#x7801;--&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">link</span> <span class="hljs-attr">rel</span>=<span class="hljs-string">&quot;stylesheet&quot;</span> <span class="hljs-attr">href</span>=<span class="hljs-string">&quot;login_e31e214b.css&quot;</span>&gt;</span>
<span class="hljs-comment">&lt;!--&#x6CE8;&#x5165; google_analytics &#x4E2D;&#x7684; JS &#x4EE3;&#x7801;--&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span>&gt;</span><span class="javascript">(<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">i,s,o,g,r,a,m</span>)</span>{i[<span class="hljs-string">&apos;GoogleAnalyticsObject&apos;</span>]=r;i[r]=i[r]||<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
    (i[r].q=i[r].q||[]).push(<span class="hljs-built_in">arguments</span>)},i[r].l=<span class="hljs-number">1</span>*<span class="hljs-keyword">new</span> <span class="hljs-built_in">Date</span>();a=s.createElement(o),
    m=s.getElementsByTagName(o)[<span class="hljs-number">0</span>];a.async=<span class="hljs-number">1</span>;a.src=g;m.parentNode.insertBefore(a,m)
})(<span class="hljs-built_in">window</span>,<span class="hljs-built_in">document</span>,<span class="hljs-string">&apos;script&apos;</span>,<span class="hljs-string">&apos;https://www.google-analytics.com/analytics.js&apos;</span>,<span class="hljs-string">&apos;ga&apos;</span>);
ga(<span class="hljs-string">&apos;create&apos;</span>, <span class="hljs-string">&apos;UA-XXXXX-Y&apos;</span>, <span class="hljs-string">&apos;auto&apos;</span>);
ga(<span class="hljs-string">&apos;send&apos;</span>, <span class="hljs-string">&apos;pageview&apos;</span>);</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-comment">&lt;!--&#x5F02;&#x6B65;&#x52A0;&#x8F7D; Disqus &#x8BC4;&#x8BBA;--&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">async</span>=<span class="hljs-string">&quot;&quot;</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;https://dive-into-webpack.disqus.com/embed.js&quot;</span>&gt;</span><span class="undefined"></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;app&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-comment">&lt;!--&#x4ECE;&#x591A;&#x4E2A;&#x9875;&#x9762;&#x4E2D;&#x62BD;&#x79BB;&#x51FA;&#x7684;&#x516C;&#x5171; JavaScript &#x4EE3;&#x7801;--&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;common_a1d9142f.js&quot;</span>&gt;</span><span class="undefined"></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-comment">&lt;!--&#x53EA;&#x6709;&#x8FD9;&#x4E2A;&#x9875;&#x9762;&#x9700;&#x8981;&#x7684; JavaScript &#x4EE3;&#x7801;--&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;login_f926c4e6.js&quot;</span>&gt;</span><span class="undefined"></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-comment">&lt;!--Disqus &#x8BC4;&#x8BBA;&#x5BB9;&#x5668;--&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;disqus_thread&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>&#x6784;&#x5EFA;&#x51FA;&#x7684;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#x4E3A;&#xFF1A;</p>
<pre><code>dist
&#x251C;&#x2500;&#x2500; common_029086ff.js
&#x251C;&#x2500;&#x2500; common_7cc98ad0.css
&#x251C;&#x2500;&#x2500; index.html
&#x251C;&#x2500;&#x2500; index_04c08fbf.css
&#x251C;&#x2500;&#x2500; index_b3d3761c.js
&#x251C;&#x2500;&#x2500; login.html
&#x251C;&#x2500;&#x2500; login_0a3feca9.js
&#x2514;&#x2500;&#x2500; login_e31e214b.css
</code></pre><p>&#x5982;&#x679C;&#x6309;&#x7167;&#x4E0A;&#x8282;&#x7684;&#x601D;&#x8DEF;&#xFF0C;&#x53EF;&#x80FD;&#x9700;&#x8981;&#x4E3A;&#x6BCF;&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;&#x914D;&#x7F6E;&#x4E00;&#x6BB5;&#x5982;&#x4E0B;&#x4EE3;&#x7801;&#xFF1A;</p>
<pre><code class="lang-js"><span class="hljs-keyword">new</span> WebPlugin({
  template: <span class="hljs-string">&apos;./template.html&apos;</span>, <span class="hljs-comment">// HTML &#x6A21;&#x7248;&#x6587;&#x4EF6;&#x6240;&#x5728;&#x7684;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;</span>
  filename: <span class="hljs-string">&apos;login.html&apos;</span> <span class="hljs-comment">// &#x8F93;&#x51FA;&#x7684; HTML &#x7684;&#x6587;&#x4EF6;&#x540D;&#x79F0;</span>
})
</code></pre>
<p>&#x5E76;&#x4E14;&#x628A;&#x9875;&#x9762;&#x5BF9;&#x5E94;&#x7684;&#x5165;&#x53E3;&#x52A0;&#x5165;&#x5230; <code>enrty</code> &#x914D;&#x7F6E;&#x9879;&#x4E2D;&#xFF0C;&#x5C31;&#x50CF;&#x8FD9;&#x6837;&#xFF1A;</p>
<pre><code class="lang-js">entry: {
  index: <span class="hljs-string">&apos;./pages/index/index.js&apos;</span>,<span class="hljs-comment">// &#x9875;&#x9762; index.html &#x7684;&#x5165;&#x53E3;&#x6587;&#x4EF6;</span>
  login: <span class="hljs-string">&apos;./pages/login/index.js&apos;</span>,<span class="hljs-comment">// &#x9875;&#x9762; login.html &#x7684;&#x5165;&#x53E3;&#x6587;&#x4EF6;</span>
}
</code></pre>
<p>&#x5F53;&#x6709;&#x65B0;&#x9875;&#x9762;&#x52A0;&#x5165;&#x65F6;&#x5C31;&#x9700;&#x8981;&#x4FEE;&#x6539; Webpack &#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF0C;&#x65B0;&#x63D2;&#x5165;&#x4E00;&#x6BB5;&#x4EE5;&#x4E0A;&#x4EE3;&#x7801;&#xFF0C;&#x8FD9;&#x4F1A;&#x5BFC;&#x81F4;&#x6784;&#x5EFA;&#x4EE3;&#x7801;&#x96BE;&#x4EE5;&#x7EF4;&#x62A4;&#x800C;&#x4E14;&#x6613;&#x9519;&#x3002;</p>
<h2 id="&#x89E3;&#x51B3;&#x65B9;&#x6848;">&#x89E3;&#x51B3;&#x65B9;&#x6848;</h2>
<p>&#x4E0A;&#x4E00;&#x8282;&#x4E2D;&#x7684; <a href="https://github.com/gwuhaolin/web-webpack-plugin" target="_blank">web-webpack-plugin</a> &#x63D2;&#x4EF6;&#x4E5F;&#x5185;&#x7F6E;&#x4E86;&#x89E3;&#x51B3;&#x8FD9;&#x4E2A;&#x95EE;&#x9898;&#x7684;&#x65B9;&#x6CD5;&#xFF0C;&#x4E0A;&#x4E00;&#x8282;&#x4E2D;&#x53EA;&#x4F7F;&#x7528;&#x4E86;&#x5B83;&#x7684; <code>WebPlugin</code>&#xFF0C;
&#x8FD9;&#x8282;&#x5C06;&#x4F7F;&#x7528;&#x5B83;&#x7684; <code>AutoWebPlugin</code> &#x6765;&#x89E3;&#x51B3;&#x4EE5;&#x4E0A;&#x95EE;&#x9898;&#xFF0C;&#x4F7F;&#x7528;&#x65B9;&#x6CD5;&#x975E;&#x5E38;&#x7B80;&#x5355;&#xFF0C;&#x4E0B;&#x9762;&#x6765;&#x6559;&#x4F60;&#x5177;&#x4F53;&#x5982;&#x4F55;&#x4F7F;&#x7528;&#x3002;</p>
<p>&#x9879;&#x76EE;&#x6E90;&#x7801;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code>&#x251C;&#x2500;&#x2500; pages
&#x2502;   &#x251C;&#x2500;&#x2500; index
&#x2502;   &#x2502;   &#x251C;&#x2500;&#x2500; index.css // &#x8BE5;&#x9875;&#x9762;&#x5355;&#x72EC;&#x9700;&#x8981;&#x7684; CSS &#x6837;&#x5F0F;
&#x2502;   &#x2502;   &#x2514;&#x2500;&#x2500; index.js // &#x8BE5;&#x9875;&#x9762;&#x7684;&#x5165;&#x53E3;&#x6587;&#x4EF6;
&#x2502;   &#x2514;&#x2500;&#x2500; login
&#x2502;       &#x251C;&#x2500;&#x2500; index.css
&#x2502;       &#x2514;&#x2500;&#x2500; index.js
&#x251C;&#x2500;&#x2500; common.css // &#x6240;&#x6709;&#x9875;&#x9762;&#x90FD;&#x9700;&#x8981;&#x7684;&#x516C;&#x5171; CSS &#x6837;&#x5F0F;
&#x251C;&#x2500;&#x2500; google_analytics.js
&#x251C;&#x2500;&#x2500; template.html
&#x2514;&#x2500;&#x2500; webpack.config.js
</code></pre><p>&#x4ECE;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#x4E2D;&#x53EF;&#x4EE5;&#x770B;&#x6210;&#x51FA;&#x4E0B;&#x51E0;&#x70B9;&#x8981;&#x6C42;&#xFF1A;</p>
<ul>
<li>&#x6240;&#x6709;&#x5355;&#x9875;&#x5E94;&#x7528;&#x7684;&#x4EE3;&#x7801;&#x90FD;&#x9700;&#x8981;&#x653E;&#x5230;&#x4E00;&#x4E2A;&#x76EE;&#x5F55;&#x4E0B;&#xFF0C;&#x4F8B;&#x5982;&#x90FD;&#x653E;&#x5728; pages &#x76EE;&#x5F55;&#x4E0B;&#xFF1B;</li>
<li>&#x4E00;&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;&#x4E00;&#x4E2A;&#x5355;&#x72EC;&#x7684;&#x6587;&#x4EF6;&#x5939;&#xFF0C;&#x4F8B;&#x5982;&#x6700;&#x540E;&#x751F;&#x6210;&#x7684; <code>index.html</code> &#x76F8;&#x5173;&#x7684;&#x4EE3;&#x7801;&#x90FD;&#x5728; <code>index</code> &#x76EE;&#x5F55;&#x4E0B;&#xFF0C;<code>login.html</code> &#x540C;&#x7406;&#xFF1B;</li>
<li>&#x6BCF;&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;&#x7684;&#x76EE;&#x5F55;&#x4E0B;&#x90FD;&#x6709;&#x4E00;&#x4E2A; <code>index.js</code> &#x6587;&#x4EF6;&#x4F5C;&#x4E3A;&#x5165;&#x53E3;&#x6267;&#x884C;&#x6587;&#x4EF6;&#x3002; </li>
</ul>
<blockquote>
<p>&#x867D;&#x7136; <code>AutoWebPlugin</code> &#x5F3A;&#x5236;&#x6027;&#x7684;&#x89C4;&#x5B9A;&#x4E86;&#x9879;&#x76EE;&#x90E8;&#x5206;&#x7684;&#x76EE;&#x5F55;&#x7ED3;&#x6784;&#xFF0C;&#x4F46;&#x4ECE;&#x5B9E;&#x6218;&#x7ECF;&#x9A8C;&#x6765;&#x770B;&#x8FD9;&#x662F;&#x4E00;&#x79CD;&#x4F18;&#x96C5;&#x7684;&#x76EE;&#x5F55;&#x89C4;&#x8303;&#xFF0C;&#x5408;&#x7406;&#x7684;&#x62C6;&#x5206;&#x4E86;&#x4EE3;&#x7801;&#xFF0C;&#x53C8;&#x80FD;&#x8BA9;&#x65B0;&#x4EBA;&#x5FEB;&#x901F;&#x7684;&#x770B;&#x61C2;&#x9879;&#x76EE;&#x7ED3;&#x6784;&#xFF0C;&#x4E5F;&#x65B9;&#x4FBF;&#x65E5;&#x540E;&#x7684;&#x7EF4;&#x62A4;&#x3002;</p>
</blockquote>
<p>Webpack &#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4FEE;&#x6539;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> { AutoWebPlugin } = <span class="hljs-built_in">require</span>(<span class="hljs-string">&apos;web-webpack-plugin&apos;</span>);

<span class="hljs-comment">// &#x4F7F;&#x7528;&#x672C;&#x6587;&#x7684;&#x4E3B;&#x89D2; AutoWebPlugin&#xFF0C;&#x81EA;&#x52A8;&#x5BFB;&#x627E; pages &#x76EE;&#x5F55;&#x4E0B;&#x7684;&#x6240;&#x6709;&#x76EE;&#x5F55;&#xFF0C;&#x628A;&#x6BCF;&#x4E00;&#x4E2A;&#x76EE;&#x5F55;&#x770B;&#x6210;&#x4E00;&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;</span>
<span class="hljs-keyword">const</span> autoWebPlugin = <span class="hljs-keyword">new</span> AutoWebPlugin(<span class="hljs-string">&apos;pages&apos;</span>, {
  template: <span class="hljs-string">&apos;./template.html&apos;</span>, <span class="hljs-comment">// HTML &#x6A21;&#x7248;&#x6587;&#x4EF6;&#x6240;&#x5728;&#x7684;&#x6587;&#x4EF6;&#x8DEF;&#x5F84;</span>
  postEntrys: [<span class="hljs-string">&apos;./common.css&apos;</span>],<span class="hljs-comment">// &#x6240;&#x6709;&#x9875;&#x9762;&#x90FD;&#x4F9D;&#x8D56;&#x8FD9;&#x4EFD;&#x901A;&#x7528;&#x7684; CSS &#x6837;&#x5F0F;&#x6587;&#x4EF6;</span>
  <span class="hljs-comment">// &#x63D0;&#x53D6;&#x51FA;&#x6240;&#x6709;&#x9875;&#x9762;&#x516C;&#x5171;&#x7684;&#x4EE3;&#x7801;</span>
  commonsChunk: {
    name: <span class="hljs-string">&apos;common&apos;</span>,<span class="hljs-comment">// &#x63D0;&#x53D6;&#x51FA;&#x516C;&#x5171;&#x4EE3;&#x7801; Chunk &#x7684;&#x540D;&#x79F0;</span>
  },
});

<span class="hljs-built_in">module</span>.exports = {
  <span class="hljs-comment">// AutoWebPlugin &#x4F1A;&#x4E3A;&#x5BFB;&#x627E;&#x5230;&#x7684;&#x6240;&#x6709;&#x5355;&#x9875;&#x5E94;&#x7528;&#xFF0C;&#x751F;&#x6210;&#x5BF9;&#x5E94;&#x7684;&#x5165;&#x53E3;&#x914D;&#x7F6E;&#xFF0C;</span>
  <span class="hljs-comment">// autoWebPlugin.entry &#x65B9;&#x6CD5;&#x53EF;&#x4EE5;&#x83B7;&#x53D6;&#x5230;&#x6240;&#x6709;&#x7531; autoWebPlugin &#x751F;&#x6210;&#x7684;&#x5165;&#x53E3;&#x914D;&#x7F6E;</span>
  entry: autoWebPlugin.entry({
    <span class="hljs-comment">// &#x8FD9;&#x91CC;&#x53EF;&#x4EE5;&#x52A0;&#x5165;&#x4F60;&#x989D;&#x5916;&#x9700;&#x8981;&#x7684; Chunk &#x5165;&#x53E3;</span>
  }),
  plugins: [
    autoWebPlugin,
  ],
};
</code></pre>
<blockquote>
<p>&#x4EE5;&#x4E0A;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E3A;&#x4E86;&#x91CD;&#x70B9;&#x5C55;&#x793A;&#x51FA;&#x672C;&#x8282;&#x4FA7;&#x91CD;&#x4FEE;&#x6539;&#x7684;&#x90E8;&#x5206;&#xFF0C;&#x7701;&#x7565;&#x4E86;&#x90E8;&#x5206;&#x548C;&#x4E0A;&#x4E00;&#x8282;&#x4E00;&#x81F4;&#x7684;&#x4EE3;&#x7801;&#xFF0C;&#x5B8C;&#x6574;&#x4EE3;&#x7801;&#x53EF;&#x4EE5;&#x53C2;&#x7167;&#x4E0A;&#x4E00;&#x8282;&#x6216;&#x8005;&#x4E0B;&#x8F7D;&#x672C;&#x9879;&#x76EE;&#x5B8C;&#x6574;&#x4EE3;&#x7801;&#x3002;</p>
</blockquote>
<p><code>AutoWebPlugin</code> &#x4F1A;&#x627E;&#x51FA; <code>pages</code> &#x76EE;&#x5F55;&#x4E0B;&#x7684;2&#x4E2A;&#x6587;&#x4EF6;&#x5939; <code>index</code> &#x548C; <code>login</code>&#xFF0C;&#x628A;&#x8FD9;&#x4E24;&#x4E2A;&#x6587;&#x4EF6;&#x5939;&#x770B;&#x6210;&#x4E24;&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;&#x3002;
&#x5E76;&#x4E14;&#x5206;&#x522B;&#x4E3A;&#x6BCF;&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;&#x751F;&#x6210;&#x4E00;&#x4E2A; Chunk &#x914D;&#x7F6E;&#x548C; <code>WebPlugin</code> &#x914D;&#x7F6E;&#x3002;
&#x6BCF;&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;&#x7684; Chunk &#x540D;&#x79F0;&#x5C31;&#x7B49;&#x4E8E;&#x6587;&#x4EF6;&#x5939;&#x7684;&#x540D;&#x79F0;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x8BF4; <code>autoWebPlugin.entry()</code> &#x65B9;&#x6CD5;&#x8FD4;&#x56DE;&#x7684;&#x5185;&#x5BB9;&#x5176;&#x5B9E;&#x662F;&#xFF1A;</p>
<pre><code class="lang-json">{
  <span class="hljs-string">&quot;index&quot;</span>:[<span class="hljs-string">&quot;./pages/index/index.js&quot;</span>,<span class="hljs-string">&quot;./common.css&quot;</span>],
  <span class="hljs-string">&quot;login&quot;</span>:[<span class="hljs-string">&quot;./pages/login/index.js&quot;</span>,<span class="hljs-string">&quot;./common.css&quot;</span>]
}
</code></pre>
<p>&#x4F46;&#x8FD9;&#x4E9B;&#x4E8B;&#x60C5; <code>AutoWebPlugin</code> &#x90FD;&#x4F1A;&#x81EA;&#x52A8;&#x4E3A;&#x4F60;&#x5B8C;&#x6210;&#xFF0C;&#x4F60;&#x4E0D;&#x7528;&#x64CD;&#x5FC3;&#xFF0C;&#x660E;&#x767D;&#x5927;&#x81F4;&#x539F;&#x7406;&#x5373;&#x53EF;&#x3002;</p>
<p><code>template.html</code> &#x6A21;&#x7248;&#x6587;&#x4EF6;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">html</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">head</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">meta</span> <span class="hljs-attr">charset</span>=<span class="hljs-string">&quot;UTF-8&quot;</span>&gt;</span>
  <span class="hljs-comment">&lt;!--&#x5728;&#x8FD9;&#x6CE8;&#x5165;&#x8BE5;&#x9875;&#x9762;&#x6240;&#x4F9D;&#x8D56;&#x4F46;&#x6CA1;&#x6709;&#x624B;&#x52A8;&#x5BFC;&#x5165;&#x7684; CSS--&gt;</span>
  <span class="hljs-comment">&lt;!--STYLE--&gt;</span>
  <span class="hljs-comment">&lt;!--&#x6CE8;&#x5165; google_analytics &#x4E2D;&#x7684; JS &#x4EE3;&#x7801;--&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;./google_analytics.js?_inline&quot;</span>&gt;</span><span class="undefined"></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
  <span class="hljs-comment">&lt;!--&#x5F02;&#x6B65;&#x52A0;&#x8F7D; Disqus &#x8BC4;&#x8BBA;--&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">src</span>=<span class="hljs-string">&quot;https://dive-into-webpack.disqus.com/embed.js&quot;</span> <span class="hljs-attr">async</span>&gt;</span><span class="undefined"></span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">head</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;app&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-comment">&lt;!--&#x5728;&#x8FD9;&#x6CE8;&#x5165;&#x8BE5;&#x9875;&#x9762;&#x6240;&#x4F9D;&#x8D56;&#x4F46;&#x6CA1;&#x6709;&#x624B;&#x52A8;&#x5BFC;&#x5165;&#x7684; JavaScript--&gt;</span>
<span class="hljs-comment">&lt;!--SCRIPT--&gt;</span>
<span class="hljs-comment">&lt;!--Disqus &#x8BC4;&#x8BBA;&#x5BB9;&#x5668;--&gt;</span>
<span class="hljs-tag">&lt;<span class="hljs-name">div</span> <span class="hljs-attr">id</span>=<span class="hljs-string">&quot;disqus_thread&quot;</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">div</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">body</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">html</span>&gt;</span>
</code></pre>
<p>&#x6CE8;&#x610F;&#x5230;&#x6A21;&#x7248;&#x6587;&#x4EF6;&#x4E2D;&#x51FA;&#x73B0;&#x4E86;2&#x4E2A;&#x91CD;&#x8981;&#x7684;&#x65B0;&#x5173;&#x952E;&#x5B57; <code>&lt;!--STYLE--&gt;</code> &#x548C; <code>&lt;!--SCRIPT--&gt;</code>&#xFF0C;&#x5B83;&#x4EEC;&#x662F;&#x4EC0;&#x4E48;&#x610F;&#x601D;&#x5462;&#xFF1F;</p>
<p>&#x7531;&#x4E8E;&#x8FD9;&#x4E2A;&#x6A21;&#x7248;&#x6587;&#x4EF6;&#x88AB;&#x5F53;&#x4F5C;&#x9879;&#x76EE;&#x4E2D;&#x6240;&#x6709;&#x5355;&#x9875;&#x5E94;&#x7528;&#x7684;&#x6A21;&#x7248;&#xFF0C;&#x5C31;&#x4E0D;&#x80FD;&#x518D;&#x50CF;&#x4E0A;&#x4E00;&#x8282;&#x4E2D;&#x76F4;&#x63A5;&#x5199; Chunk &#x7684;&#x540D;&#x79F0;&#x53BB;&#x5F15;&#x5165;&#x8D44;&#x6E90;&#xFF0C;&#x56E0;&#x4E3A;&#x9700;&#x8981;&#x88AB;&#x6CE8;&#x5165;&#x5230;&#x5F53;&#x524D;&#x9875;&#x9762;&#x7684; Chunk &#x540D;&#x79F0;&#x662F;&#x4E0D;&#x5B9A;&#x7684;&#xFF0C;&#x6BCF;&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;&#x90FD;&#x4F1A;&#x6709;&#x81EA;&#x5DF1;&#x7684;&#x540D;&#x79F0;&#x3002;
<code>&lt;!--STYLE--&gt;</code> &#x548C; <code>&lt;!--SCRIPT--&gt;</code> &#x7684;&#x4F5C;&#x7528;&#x5728;&#x4E8E;&#x4FDD;&#x8BC1;&#x8BE5;&#x9875;&#x9762;&#x6240;&#x4F9D;&#x8D56;&#x7684;&#x8D44;&#x6E90;&#x90FD;&#x4F1A;&#x88AB;&#x6CE8;&#x5165;&#x5230;&#x751F;&#x6210;&#x7684; HTML &#x6A21;&#x7248;&#x91CC;&#x53BB;&#x3002;</p>
<p>web-webpack-plugin &#x80FD;&#x5206;&#x6790;&#x51FA;&#x6BCF;&#x4E2A;&#x9875;&#x9762;&#x4F9D;&#x8D56;&#x54EA;&#x4E9B;&#x8D44;&#x6E90;&#xFF0C;&#x4F8B;&#x5982;&#x5BF9;&#x4E8E; <code>login.html</code> &#x6765;&#x8BF4;&#xFF0C;&#x63D2;&#x4EF6;&#x53EF;&#x4EE5;&#x786E;&#x5B9A;&#x8BE5;&#x9875;&#x9762;&#x4F9D;&#x8D56;&#x4EE5;&#x4E0B;&#x8D44;&#x6E90;&#xFF1A;</p>
<ul>
<li>&#x6240;&#x6709;&#x9875;&#x9762;&#x90FD;&#x4F9D;&#x8D56;&#x7684;&#x516C;&#x5171; CSS &#x4EE3;&#x7801; <code>common.css</code>&#xFF1B;</li>
<li>&#x6240;&#x6709;&#x9875;&#x9762;&#x90FD;&#x4F9D;&#x8D56;&#x7684;&#x516C;&#x5171; JavaScrip &#x4EE3;&#x7801; <code>common.js</code>&#xFF1B;</li>
<li>&#x53EA;&#x6709;&#x8FD9;&#x4E2A;&#x9875;&#x9762;&#x4F9D;&#x8D56;&#x7684; CSS &#x4EE3;&#x7801; <code>login.css</code>&#xFF1B;</li>
<li>&#x53EA;&#x6709;&#x8FD9;&#x4E2A;&#x9875;&#x9762;&#x4F9D;&#x8D56;&#x7684; JavaScrip &#x4EE3;&#x7801; <code>login.css</code>&#x3002;</li>
</ul>
<p>&#x7531;&#x4E8E;&#x6A21;&#x7248;&#x6587;&#x4EF6; <code>template.html</code> &#x91CC;&#x6CA1;&#x6709;&#x6307;&#x51FA;&#x5F15;&#x5165;&#x8FD9;&#x4E9B;&#x4F9D;&#x8D56;&#x8D44;&#x6E90;&#x7684; HTML &#x8BED;&#x53E5;&#xFF0C;&#x63D2;&#x4EF6;&#x4F1A;&#x81EA;&#x52A8;&#x5C06;&#x6CA1;&#x6709;&#x624B;&#x52A8;&#x5BFC;&#x5165;&#x4F46;&#x9875;&#x9762;&#x4F9D;&#x8D56;&#x7684;&#x8D44;&#x6E90;&#x6309;&#x7167;&#x4E0D;&#x540C;&#x7C7B;&#x578B;&#x6CE8;&#x5165;&#x5230; <code>&lt;!--STYLE--&gt;</code> &#x548C; <code>&lt;!--SCRIPT--&gt;</code> &#x6240;&#x5728;&#x7684;&#x4F4D;&#x7F6E;&#x3002;</p>
<ul>
<li>CSS &#x7C7B;&#x578B;&#x7684;&#x6587;&#x4EF6;&#x6CE8;&#x5165;&#x5230; <code>&lt;!--STYLE--&gt;</code> &#x6240;&#x5728;&#x7684;&#x4F4D;&#x7F6E;&#xFF0C;&#x5982;&#x679C; <code>&lt;!--STYLE--&gt;</code> &#x4E0D;&#x5B58;&#x5728;&#x5C31;&#x6CE8;&#x5165;&#x5230; HTML HEAD &#x6807;&#x7B7E;&#x7684;&#x6700;&#x540E;&#xFF1B;</li>
<li>JavaScrip &#x7C7B;&#x578B;&#x7684;&#x6587;&#x4EF6;&#x6CE8;&#x5165;&#x5230; <code>&lt;!--SCRIPT--&gt;</code> &#x6240;&#x5728;&#x7684;&#x4F4D;&#x7F6E;&#xFF0C;&#x5982;&#x679C; <code>&lt;!--SCRIPT--&gt;</code> &#x4E0D;&#x5B58;&#x5728;&#x5C31;&#x6CE8;&#x5165;&#x5230; HTML BODY &#x6807;&#x7B7E;&#x7684;&#x6700;&#x540E;&#x3002;</li>
</ul>
<p>&#x5982;&#x679C;&#x540E;&#x7EED;&#x6709;&#x65B0;&#x7684;&#x9875;&#x9762;&#x9700;&#x8981;&#x5F00;&#x53D1;&#xFF0C;&#x53EA;&#x9700;&#x8981;&#x5728; <code>pages</code> &#x76EE;&#x5F55;&#x4E0B;&#x65B0;&#x5EFA;&#x4E00;&#x4E2A;&#x76EE;&#x5F55;&#xFF0C;&#x76EE;&#x5F55;&#x540D;&#x79F0;&#x53D6;&#x4E3A;&#x8F93;&#x51FA; HTML &#x6587;&#x4EF6;&#x7684;&#x540D;&#x79F0;&#xFF0C;&#x76EE;&#x5F55;&#x4E0B;&#x653E;&#x8FD9;&#x4E2A;&#x9875;&#x9762;&#x76F8;&#x5173;&#x7684;&#x4EE3;&#x7801;&#x5373;&#x53EF;&#xFF0C;&#x65E0;&#x9700;&#x6539;&#x52A8;&#x6784;&#x5EFA;&#x4EE3;&#x7801;&#x3002;</p>
<p>&#x7531;&#x4E8E; <code>AutoWebPlugin</code> &#x662F;&#x95F4;&#x63A5;&#x7684;&#x901A;&#x8FC7;&#x4E0A;&#x4E00;&#x8282;&#x63D0;&#x5230;&#x7684; <code>WebPlugin</code> &#x5B9E;&#x73B0;&#x7684;&#xFF0C;<code>WebPlugin</code> &#x652F;&#x6301;&#x7684;&#x529F;&#x80FD; <code>AutoWebPlugin</code> &#x90FD;&#x652F;&#x6301;&#x3002;</p>
<p><code>AutoWebPlugin</code> &#x63D2;&#x4EF6;&#x8FD8;&#x652F;&#x6301;&#x4E00;&#x4E9B;&#x5176;&#x5B83;&#x66F4;&#x9AD8;&#x7EA7;&#x7684;&#x7528;&#x6CD5;&#xFF0C;&#x8BE6;&#x60C5;&#x53EF;&#x4EE5;&#x8BBF;&#x95EE;&#x8BE5;<a href="https://github.com/gwuhaolin/web-webpack-plugin" target="_blank">&#x9879;&#x76EE;&#x4E3B;&#x9875;</a>&#x9605;&#x8BFB;&#x6587;&#x6863;&#x3002;</p>
<blockquote>
<p>&#x672C;&#x5B9E;&#x4F8B;<a href="http://webpack.wuhaolin.cn/3-10&#x7BA1;&#x7406;&#x591A;&#x4E2A;&#x5355;&#x9875;&#x5E94;&#x7528;.zip" target="_blank">&#x63D0;&#x4F9B;&#x9879;&#x76EE;&#x5B8C;&#x6574;&#x4EE3;&#x7801;</a></p>
</blockquote>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="3-9为单页应用生成HTML.html" class="navigation navigation-prev " aria-label="Previous page: 3-9 为单页应用生成 HTML">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="3-11构建同构应用.html" class="navigation navigation-next " aria-label="Next page: 3-11 构建同构应用">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"3-10 管理多个单页应用","level":"1.5.10","depth":2,"next":{"title":"3-11 构建同构应用","level":"1.5.11","depth":2,"path":"3实战/3-11构建同构应用.md","ref":"3实战/3-11构建同构应用.md","articles":[]},"previous":{"title":"3-9 为单页应用生成 HTML","level":"1.5.9","depth":2,"path":"3实战/3-9为单页应用生成HTML.md","ref":"3实战/3-9为单页应用生成HTML.md","articles":[]},"dir":"ltr"},"config":{"plugins":["github-buttons"],"root":"./docs","styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"github-buttons":{"buttons":[{"user":"gwuhaolin","type":"follow","size":"small","width":"150"},{"user":"gwuhaolin","repo":"dive-into-webpack","type":"star","size":"small"}]},"sharing":{"facebook":false,"twitter":false,"google":false,"weibo":true,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"吴浩麟","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"isbn":"9787121331725","variables":{},"title":"深入浅出 Webpack","language":"zh-hans","gitbook":"*","description":"本书按照入门、配置、实战、优化、原理的路线层层深入，涵盖了 Webpack 的方方面面。对于小白，本书可以作为 Webpack 入门教程，对于老手，本书可以进一步加深你对 Webpack 的理解。"},"file":{"path":"3实战/3-10管理多个单页应用.md","mtime":"2021-07-01T07:20:17.216Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-07-01T07:20:58.537Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-github-buttons/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

